import request from '@/utils/request'

// 流程列表
export function getList (params) {
  return request({
    url: "/workflow",
    params
  });
}

// 删除流程
export function delListItem (deployId) {
  return request({
    url: `/workflow/${deployId}`,
    method: 'DELETE'
  });
}

// 获取详情
export function getDetail (deployId) {
  return request({
    url: `/workflow/${deployId}`,
  });
}

// 新增流程
export function create (data) {
  return request({
    url: `/workflow`,
    method: "POST",
    data
  });
}

// 更新流程
export function update (id, data) {
  return request({
    url: `/workflow/${id}`,
    method: "put",
    data
  });
}

// 开始流程
export function start (processDefinitionKey, data) {
  return request({
    url: `/workflow/${processDefinitionKey}/start`,
    method: "POST",
    data
  });
}

// 历史（实例）列表
export function history (params) {
  return request({
    url: `/workflow/histories`,
    params
  });
}

// 实例详情
export function instance (instanceId) {
  return request({
    url: `/workflow/history/${instanceId}`,
  });
}

// 切换流程激活状态
export function activate (id) {
  return request({
    url: `/workflow/${id}/activate`,
    method: 'PUT'
  });
}

export function nodeHistory (instanceId, activityId) {
  return request({
    url: `/workflow/history/${instanceId}/task/${activityId}`,
  });
}